home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- # $Id: usbcam.console,v 1.4 2002/09/12 16:50:18 hun Exp $
- #
- # /etc/hotplug/usb/usbcam
- #
- # Sets up newly plugged in USB camera so that the user who owns
- # the console according to pam_console can access it from user space
- #
- # Note that for this script to work, you'll need all of the following:
- # a) a line in the file /etc/hotplug/usermap that corresponds to the
- # camera you are using. You can get the correct lines for all cameras
- # supported by libgphoto2 by running "print-usb-usermap".
- # b) a setup using pam_console creates the respective lock files
- # containing the name of the respective user. You can check for that
- # by executing "echo `cat /var/{run,lock}/console.lock`" and
- # verifying the appropriate user is mentioned somewhere there.
- # c) a Linux kernel supporting hotplug and usbdevfs
- # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
- #
- # In the usermap file, the first field "usb module" should be named
- # "usbcam" like this script.
- #
-
- if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
- then
- # New code, using lock files instead of copying /dev/console permissions
- # This also works with non-gdm logins (e.g. on a virtual terminal)
- # Idea and code from Nalin Dahyabhai <nalin@redhat.com>
- if [ -f /var/run/console.lock ]
- then
- CONSOLEOWNER=`cat /var/run/console.lock`
- elif [ -f /var/lock/console.lock ]
- then
- CONSOLEOWNER=`cat /var/lock/console.lock`
- else
- CONSOLEOWNER=
- fi
- if [ -n "$CONSOLEOWNER" ]
- then
- chmod 0000 "${DEVICE}"
- chown "$CONSOLEOWNER" "${DEVICE}"
- chmod 0600 "${DEVICE}"
- fi
- fi
-
- # Mandrake Linux specific part
-
- SCRIPT=/etc/dynamic/scripts/camera.script
-
- if [ -x $SCRIPT ]; then
- if [ "${ACTION}" = "add" ]; then
- $SCRIPT add "${DEVICE}"
- if [ -n "$REMOVER" ]; then
- cat > $REMOVER <<EOF
- #!/bin/sh
-
- $SCRIPT del "${DEVICE}"
- EOF
- chmod +x $REMOVER
- fi
- fi
- fi
-
-